package com.atguigu.gmall.product.controller;


import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.BaseAttrInfo;
import com.atguigu.gmall.model.product.BaseCategory1;
import com.atguigu.gmall.model.product.BaseCategory2;
import com.atguigu.gmall.model.product.BaseCategory3;
import com.atguigu.gmall.product.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/product")
public class BaseManageController {


    @Autowired
    private ManageService manageService;


    ///admin/product/getCategory1
    @GetMapping("getCategory1")
    public Result getCategory1(){
      List<BaseCategory1> baseCategory1List = manageService.getCategory1();
      return Result.ok(baseCategory1List);
    }


    ///admin/product/getCategory2/{category1Id}
    @GetMapping("getCategory2/{category1Id}")
    public Result getCategory2(@PathVariable("category1Id") Long category1Id){
        List<BaseCategory2> baseCategory2List= manageService.getCategory2(category1Id);
        return Result.ok(baseCategory2List);
    }


    ///admin/product/getCategory3/{category2Id}
    @GetMapping("getCategory3/{category2Id}")
    public Result getCategory3(@PathVariable("category2Id") long category2Id){
       List<BaseCategory3>baseCategory3List= manageService.getCategory3(category2Id);
       return Result.ok(baseCategory3List);
    }

    //admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
    @GetMapping("attrInfoList/{category1Id}/{category2Id}/{category3Id}")
    public Result attrInfoList(@PathVariable long category1Id,
                                             @PathVariable long category2Id,
                                             @PathVariable long category3Id){
        List<BaseAttrInfo> baseAttrInfoList=manageService.getAttrInfoList(category1Id,category2Id,category3Id);
        return Result.ok(baseAttrInfoList);
    }
}
